const { defineConfig } = require('@vue/cli-service')
module.exports = defineConfig({
  transpileDependencies: true,
  devServer: {
    proxy: {
      '/tts': {
        target: 'https://earthquake.yubinux.cn',
        changeOrigin: true,
        pathRewrite: {
          '^/tts': '/tts'
        }
      }
    }
  },
  chainWebpack: config => {
    // Add TypeScript + JSX support to webpack
    config.module
      .rule('tsx')
      .test(/\.tsx$/)
      .use('babel-loader')
      .loader('babel-loader')
      .end()
      .use('ts-loader')
      .loader('ts-loader')
      .options({
        transpileOnly: true,
        appendTsSuffixTo: [/\.vue$/],
        happyPackMode: false
      })
      .end();

    // Add .tsx to resolve extensions
    config.resolve.extensions.add('.tsx');
  }
})